package com.chhlz.module.base.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chhlz.module.base.dao.BillTableDao;
import com.chhlz.module.base.model.BillTable;
import com.chhlz.module.service.BillTableService;

@Service
public class BillTableServiceImpl implements BillTableService{
	@Autowired
	private BillTableDao billTableDao;

	@Override
	public boolean isExist(int billId, int tableId) {
		boolean flag = false;
		String hql = "select * from BillTable bt where bt.billId=" + billId + " and bt.tableId=" + tableId;
		if(this.billTableDao.find(hql).size()>0)
			flag = true;
		return flag;
	}

	@Override
	public int save(BillTable t) {
		return this.billTableDao.save(t);
	}

	@Override
	public void update(BillTable t) {
		this.billTableDao.update(t);
	}

	@Override
	public void delete(int id) {
		BillTable bt = this.billTableDao.get(id);
		this.billTableDao.delete(bt);
	}

	@Override
	public List<BillTable> findAll(int page, int rows, String sort, String order) {
		return this.billTableDao.findAll(page, rows, sort, order);
	}

	@Override
	public int getTotal() {
		return this.billTableDao.countAll();
	}

}
